package net.huashitong.Project.dao;

import com.sirdc.modules.core.dao.GenericQuery;
import com.sirdc.modules.core.dao.StringDao;
import jodd.util.StringUtil;
import net.huashitong.Project.entity.RelocateSummary;
import net.huashitong.Project.filter.RelocateSummaryFilter;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class RelocateSummaryDao extends StringDao<RelocateSummary> {

    public List<RelocateSummary> queryByProjectId(String projectId){
        GenericQuery query = createQuery("obj");
        query.append(" and obj.projectId=:projectId").setParam("projectId", projectId);
        query.append(" order by obj.lastUpdateDate+0 DESC");
        return query.listResult();
    }

    public List<RelocateSummary> queryRelocateSummaryByFilter(RelocateSummaryFilter filter){
        GenericQuery query = createQuery("obj");
        if (StringUtil.isNotBlank(filter.getProjectId()))
            query.append(" and obj.projectId =:projectId").setParam("projectId",filter.getProjectId());
        query.append(" order by obj.lastUpdateDate DESC");
        return  query.listResult();
    }
}
